import { defineStore } from "pinia";
import { getLink, getOppoDetailInfo,getOppoDetailProject } from "@/server/home";
interface CounterState {
  currentPage: number | null;
  counter: number;
  linkData: any;
  getOppoDetailInfo: any;
  getProject: any;
}
export const useAllStore = defineStore("counter", {
  state: (): CounterState => ({
    currentPage: null,
    counter: 5,
    linkData: null,
    getProject: null,
    getOppoDetailInfo: null,
  }),
  actions: {
    increment(currentPage: number) {
      this.currentPage = currentPage;
    },
    async getLinkd(dat:any) {
      
      const { data } = await getLink(dat);
      this.linkData = data.value?.data || null;
    },
    async getInfoAc(dat:any) {
      const { data } = await getOppoDetailInfo(dat);
      this.getOppoDetailInfo = data.value?.data || null;
    },
    async getProjected(dat:any) {
        const { data } = await getOppoDetailProject(dat);
        // this.getProject = data.value?.data || null;
        // watch(data,()=>{
        this.getProject = data.value?.data || null;
    // })
      },
  },
  //persist定义要做判断，因为localStorage是客户端参数，所以需要加process.client
  persist: process.client && {
    storage: localStorage,
    paths: ["currentPage", "counter"],
  },
});
